#!/bin/bash

# Create a distribution that inherits from the @ohos/hispark_pegasus distribution.

npm install -g @ohos/hpm-cli

or

npm update -g @ohos/hpm-cli


hpm init -t dist

# 注 如果失败请重新在尝试，一般会成功
hpm i @ohos/hispark_pegasus
# 
# Run the distribution command.

hpm dist

# 之后使用Deveco 打开项目，目前不知道为啥不生ohos_config.json 文件，但是重新打开会生产，选择hpm框架
# 
# 配置项目
# 引入Hilink就要放弃OpenharmongDevice自带的认证功能 和 ohos 功能的加持
pushd device/hisilicon/hispark_pegasus/sdk_liteos
    ./build.sh menuconfig


# 理论上要关闭 config_ohos 
    # 修改 hm_build.sh
    # >>>>>>>>>>>>>>>>>>>>>>>>>>
    # find $OUTPUT_DST_DIR/libs/ -name '*.a' -exec cp "{}" $OHOS_LIBS_DIR  \;
    # find $CROOT/3rd_sdk/ -name '*.a' -exec cp "{}" $OHOS_LIBS_DIR  \;
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    # 同时手工删除 /build/libs/
    #     [OHOS ERROR] riscv32-unknown-elf-ld: components/hilink/lib/libhilinkdevicesdk.a(hks_rkc.c.o): in function `hks_rkc_destroy':
    # [OHOS ERROR] (.text.hks_rkc_destroy+0x0): multiple definition of `hks_rkc_destroy'; build/libs/libHwKeystoreSDK.a(hks_rkc.o):(.text.hks_rkc_destroy+0x0): first defined here
    # [OHOS ERROR] riscv32-unknown-elf-ld: components/hilink/lib/libhilinkdevicesdk.a(hks_rkc.c.o): in function `hks_rkc_init':
    # [OHOS ERROR] (.text.hks_rkc_init+0x0): multiple definition of `hks_rkc_init'; build/libs/libHwKeystoreSDK.a(hks_rkc.o):(.text.hks_rkc_init+0x0): first defined here
    # [OHOS ERROR] riscv32-unknown-elf-ld: components/hilink/lib/libhilinkdevicesdk.a(hks_rkc.c.o): in function `hks_rkc_get_kek':
    # [OHOS ERROR] (.text.hks_rkc_get_kek+0x0): multiple definition of `hks_rkc_get_kek'; build/libs/libHwKeystoreSDK.a(hks_rkc.o):(.text.hks_rkc_get_kek+0x0): first defined here
    # [OHOS ERROR] riscv32-unknown-elf-ld: components/hilink/lib/libhilinkdevicesdk.a(hks_rkc.c.o): in function `.LANCHOR1':
    # [OHOS ERROR] (.bss.g_hks_rkc_mk+0x0): multiple definition of `g_hks_rkc_mk'; build/libs/libHwKeystoreSDK.a(hks_rkc.o):(.bss.g_hks_rkc_mk+0x0): first defined here
    # [OHOS ERROR] riscv32-unknown-elf-ld: components/hilink/lib/libhilinkdevicesdk.a(hks_rkc.c.o):(.data.g_hks_rkc_mk_add_data+0x0): multiple definition of `g_hks_rkc_mk_add_data'; build/libs/libHwKeystoreSDK.a(hks_rkc.o):(.data.g_hks_rkc_mk_add_data+0x0): first defined here

    rm build/libs/libHwKeystoreSDK.a

popd


